package com.prs.crm.dao.cqunicom.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.prs.crm.dao.cqunicom.MovieDao;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.cqunicom.Movie;


/**
 * @author  WangTing
 *
 * 创建时间：2011-3-5 
 * 
 */

public class MovieDaoImpl extends BaseDaoImpl<Movie> implements MovieDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<Movie> getAllMovie() {
		// TODO Auto-generated method stub
		Criteria criteria = this.getSession().createCriteria(Movie.class);
		return criteria.list();
	}

	@Override
	public Integer delMovie() {
		return (Integer) this.getHibernateTemplate().execute(
			      new HibernateCallback() {   
						public Object doInHibernate(Session session) throws HibernateException {
							Query query = session.createQuery("delete from Movie");
							return query.executeUpdate();
				        }   
				 } );
	}

	
}
